#ifndef MYVIDEOOUTPUT_H
#define MYVIDEOOUTPUT_H

#include <QQuickPaintedItem>
#include <QImage>
#include <memory>
#include <mutex>
#include "IVideoCall.h"

// 视频（图像信息）上下文管理器
struct SwsContext;
struct AVFrame;

class MYVideoOutput : public QQuickPaintedItem, public IVideoCall
{
    Q_OBJECT
public:
    // 不允许隐式转换
    explicit MYVideoOutput(void);
    virtual ~MYVideoOutput();

    virtual void Init(int width, int height);

    // 不管成功与否都释放frame空间
    virtual void Repaint(AVFrame *frame);

signals:
    void requestFlush();

public slots:
    void flushDisplay();

protected:
    virtual void paint(QPainter *pPainter);

private:
    std::mutex mux;
    QImage m_VideoFrame;
    AVFrame *m_FrameRGB;
    SwsContext *m_SwsContext {nullptr};
};

#endif // MYVIDEOOUTPUT_H
